<%--
  Created by IntelliJ IDEA.
  User: 隼
  Date: 2017/1/22
  Time: 13:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>login</title>
    <script type="text/javascript" src="${pageContext.request.contextPath }/static/jquery-1.4.4.min.js"></script>
    <script type="text/javascript">
        function verify() {
            alert("登录");
            var name = $("#userName").val();
            var password=$("#password").val();
            $.ajax({
                ajax:"false",
                type: "POST",            //http请求方式
                url: "${pageContext.request.contextPath }/loginServer",    //服务器段url地址
                data: "name=" + name+"&password="+password,           //发送给服务器段的数据
                dataType: "xml",  //告诉JQuery返回的数据格式
                success: callback  //定义交互完成，并且服务器正确返回数据时调用的回调函数
            });
        }


        function callback(data) {
            alert("接收数据");
            var pass = $(data).find("pass").text();
            var www = $(data).find("www").text();
            if(pass=="NO"){
                alert("登陆失败");
            }else{
                window.location = "${pageContext.request.contextPath }/"+www;
            }
        }
    </script>
</head>
<body>
<div align="center">
    <h3>用户名</h3><br>
    <input type="text" id="userName" /><br>
    <h2>密码</h2><br>
    <input type="password" id="password" /><br>
    <input type="button" value="登录" onclick="verify()"/>
    </div>
</body>
</html>
